package easy;

public class Solution_1791 {

    public int findCenter(int[][] edges) {
        boolean[] array = new boolean[200002];
        for (int[] edge : edges) {
            if (array[edge[0]]) {
                return edge[0];
            } else {
                array[edge[0]] = true;
            }
            if (array[edge[1]]) {
                return edge[1];
            } else {
                array[edge[1]] = true;
            }
        }
        return -1;
    }

    /*public int findCenter(int[][] edges) {
        int[] array = new int[200002];
        for (int[] edge : edges) {
            array[edge[0]]++;
            array[edge[1]]++;
        }
        int c = (edges.length - 1) << 1;
        for (int i = 0; i < array.length; i++) {
            if (c == array[i]) {
                return i;
            }
        }
        return -1;
    }*/
}
